package cn.midas.basic.controller;

import cn.midas.basic.dto.LoginDto;
import cn.midas.basic.exception.BusinessException;
import cn.midas.basic.service.ILoginService;
import cn.midas.basic.utils.AjaxResult;
import cn.midas.org.domain.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController

@RequestMapping("/login")
public class loginController {


    @Autowired
    private ILoginService loginService;
    /**
     * @Title: settlement
     * @Description: 账号登录接口
     * @Author: Mr.She
     * @Version: 1.0
     * @Date:  2022/7/1 14:08
     * @Parameters: [department]
     * @Return cn.itsource.basic.utils.AjaxResult
     */
    @PostMapping("/account")
    public AjaxResult account(@RequestBody LoginDto loginDto){
        try {
            HashMap<String,Object> map = loginService.account(loginDto);
            return AjaxResult.me().setResultObj(map);
        } catch (BusinessException e){
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("系统繁忙，请重试！");
        }
    }
}
